<?php
defined('BASEPATH') OR exit('No direct script access allowed');

//车牌
class Chepai extends CommonController {
	function __construct(){
		parent::__construct();
		
		$this->load->mmodel('ChepaiModel','CurModel','Xianxing');
		
	}
	
	//start
	/**
	* @name 获取列表
	* @param page ture char 页面
	* @param size ture char 数量
	* @return 成功返回1
	*/
	//end
	function get_list(){
		$user_id = $this->user_id;
		
		$filter = array('chepai');
		$arr = array(
			'filter'=>$filter
		);
		
		$result = parent::_get_list($arr);
		if(!$result){
			$this->err_out($this->getError());
		}

		
		$this->data_out($result);
	}
	
	function info_out($info){
		$info['addtime'] = date('Y-m-d H:i',$info['addtime']);
		
		return $info;
	}
	
	//start
	/**
	* @name 获取信息
	* @param id ture char ID
	* @return 成功返回1
	*/
	//end
	function get_info(){
		$user_id = $this->user_id;
		
		$result = parent::_get_info();
		if(!$result){
			$this->err_out($this->getError());
		}
		
		$this->data_out($result);
	}
	
	//start
	/**
	* @name 获取信息
	* @param id ture char ID
	* @return 成功返回1
	*/
	//end
	function save(){
		
		$filter = array(
			'cat_id'=>'请选择栏目',
			'name'=>'名称不能为空',
			'price'=>'价格不能为空',
		);
		if(empty($_POST['cat_id'])){
			$this->err_out('请选择栏目');
		}
		
		$post = array('name','info','img','is_sale','cat_id','price','pos');
		$farr = array(
			'post'=>$post,
			'filter'=>$filter
		);
		$time = time();
		$result = parent::_save($farr,array('addtime'=>$time));
		if(!$result){
			$this->err_out($this->getError());
		}
		
		$this->add_log("保存木屋【{$result['id']}】信息",'role');
		
		$this->data_out($result);
	}
	


	
	//start
	/**
	* @name 删除
	* @param id ture int ID
	* @return 成功返回1
	*/
	//end
	function del(){
		
		$result = parent::_del();
		if(!$result){
			$this->err_out($this->getError());
		}
		
		
		$this->add_log("删除木屋【{$result}】信息",'role');
		$this->data_out($result);
		
	}
}

?>